home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12046 < prev    next >
Encoding:
Text File  |  1996-08-05  |  694 b   |  29 lines

  1. Path: news.production.compuserve.com!news
  2. From: Dave Taylor <100440.2732@CompuServe.COM>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: CONVERTING INTEGER TO ASCII??????
  5. Date: 28 Mar 1996 22:53:08 GMT
  6. Organization: -
  7. Message-ID: <4jf58k$ikp$1@mhade.production.compuserve.com>
  8. References: <315a0571.135066665@nntp.ix.netcom.com>
  9.  
  10.  
  11. A simple method of converting an integer to an ascii 
  12. character is to use sprintf() e.g.:
  13.  
  14. main()
  15. {
  16.     char    buf[500];
  17.  
  18.     sprintf(buf, "%d", 1234);
  19.     printf("%s", buf);
  20. }
  21.  
  22. This will 'display' the integer 1234 into the buffer 'buf'
  23. sprintf() converts each digit to the appropriate ascii
  24. character. 'buf' will therefore now contain a string of 
  25. character digits.
  26.  
  27. -- 
  28. Thanks Dave,
  29.